$(document).ready(function() {

    // GET WIDTH WINDOW
    var w_Window = $(window).width();


    // OWL CAROUSEL
    var owl = $("#owl-carousel");
    owl.owlCarousel({
        itemsCustom: [
            [0, 1],
            [450, 1],
            [600, 2],
            [700, 3],
            [900, 3],
            [1200, 4],
            [1400, 4],
            [1600, 4]
        ],
        navigation: true,
        pagination: false,
        autoPlay: true,
        stopOnHover: true
    });

    // BACK TO TOP
    $('.back-to-top').click(function() {
        $('html, body').animate({
            scrollTop: 0
        }, '1000');
        return false;
    });

    // ACCORDION
    $('.accordion .content:not(:first)').hide();
    $('.accordion .heading:first').addClass('active');
    $('.accordion .heading').click(function() {
        $('.accordion .active').removeClass('active');
        $('.accordion .content').slideUp(300);
        if ($(this).next('.content').is(':hidden') === true) {
            $(this).addClass('active');
            $(this).next('.content').slideDown(300);
        }
    });

    // CLOSE SEARCH TAG
    $("div.search-more").find("i").click(function() {
        $(this).parent("a").fadeOut(100);
    });

    // GET HEIGHT IFRAME
    var $wheight = $(window).height();
    var $fheight = $wheight - 54;
    $('#theme-live-demo').height($fheight);


    var menuLeft = document.getElementById('cbp-spmenu-s1'),
        body = document.body;

    showLeft.onclick = function() {
        classie.toggle(this, 'active');
        classie.toggle(menuLeft, 'cbp-spmenu-open');
        disableOther('showLeft');
    };

    function disableOther(button) {
        if (button !== 'showLeft') {
            classie.toggle(showLeft, 'disabled');
        }
    }
});

$(window).resize(function() {
    var $wheight = $(window).height();
    var $fheight = $wheight - 54;
    $('#theme-live-demo').height($fheight);
});